import { configureStore } from "@reduxjs/toolkit";
import counterReducer from "./modules/counter";
import recommendReducer from "@/views/discover/c-views/recommend/store/recommend";
import { TypedUseSelectorHook, useSelector, useDispatch } from "react-redux";
const store = configureStore({
	reducer: {
		counter: counterReducer,
		recommend: recommendReducer,
	},
});

// store state hook => useAppSelector
type GetStateFnType = typeof store.getState;
export type IRootState = ReturnType<GetStateFnType>;
export const useAppSelector: TypedUseSelectorHook<IRootState> = useSelector;

// dispatch hook => useAppDispatch
export type AppDispatch = typeof store.dispatch;
export const useAppDispatch: () => AppDispatch = useDispatch;

export default store;
